<?php
namespace app\index\model;

use think\Model;
use think\Db;

class DetailModel extends Model
{
  public function select($gid){//查询获取对应商品
    return $res = Db::table('gjc_goods')->where('gid',$gid)->find();
  }
  public function change($gid,$user,$change_id){//客户事件查看表
    $where = [
      'uid'=>$user,
      'change_id'=>$change_id,
      'param1'=>$gid
    ];
    return $res = Db::table('gjc_change')->where($where)->find();
  }
  public function addChange($gid,$user,$change_id){
    $data = [
      'uid'=>$user,
      'change_id'=>$change_id,
      'param1'=>$gid,
      'time'=>time()
    ];
    return $res = Db::table('gjc_change')->insert($data);
  }
  public function goodsLikes($gid,$numType){//获取数量
    return $res = Db::table('gjc_goods')->where('gid',$gid)->value($numType);
  }
  public function upNum($gid,$numType,$newNum){//修改数量
    return $res = Db::table('gjc_goods')->where('gid',$gid)->update([$numType=>$newNum]);
  }
}